// ADS Point lighting Shader
#version 130

in vec4 fmat_ambient;
in vec4 fmat_diffuse;
in vec4 fmat_specular;
in float fmat_shininess;

smooth in vec3 fNormal;
smooth in vec3 fLightDir;
smooth in vec3 fCameraDir;

out vec4 pixelColor;

void main(void)
{
  vec4 fragColor = fmat_ambient;

  float diffInt = max(0.0, dot(fNormal, fLightDir));

  fragColor += fmat_diffuse*diffInt;

  vec3 reflection = normalize(reflect(-fLightDir, fNormal));
  float spec = max(0.0, dot(fCameraDir, reflection));
  if(diffInt != 0)
  {
    spec = pow(spec, fmat_shininess);
    fragColor += fmat_specular*spec;
  }
  
  pixelColor = fragColor;
}
    
